package com.example.javastream.demo;

import java.util.stream.Stream;

public class MatchEndOps {
    public static void main(String[] args) {
        Stream<Integer> integerStream = Stream.of(1, 2, 3, 4, 5);
        // 全部符合条件
        boolean allMatch = integerStream.allMatch(i -> i < 6);
        System.out.println(allMatch);

        System.out.println("1============");
        integerStream = Stream.of(1, 2, 3, 4, 5);
        // 全部不符合
        boolean noneMatch = integerStream.noneMatch(i -> i > 2);
        System.out.println(noneMatch);

        System.out.println("2============");
        integerStream = Stream.of(1, 2, 3, 4, 5);
        // 部分符合
        boolean anyMatch = integerStream.anyMatch(i -> i > 2);
        System.out.println(anyMatch);

    }
}
